package com.xhwl.logistics.config;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * <p>
 *
 * </p>
 *
 * @author Lu.Aaron
 * @since 2021-02-08
 */
@Configuration
public class Swagger2Config {

    private static final String NAME = "Aaron";

    @Bean
    public Docket createDocket() {
        return new Docket(DocumentationType.SWAGGER_2).
                apiInfo(apiInfo())
                .select()
                //.apis(RequestHandlerSelectors.basePackage("com.xhwl.logistics.controller"))
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo apiInfo() {
        return new ApiInfoBuilder().
                title("物流系统后台api")
                .description("物流系统后台api在线文档")
                .contact(new Contact(NAME, "", ""))
                .version("1.0")
                .build();
    }

}
